package com.ruoyi.mq;

import com.ruoyi.common.config.datasource.DynamicDataSourceContextHolder;
import com.ruoyi.common.utils.exception.AjaxException;
import com.ruoyi.system.service.other.MqReceiveService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@RabbitListener(queues = "ipay_dead_rounting_key")
public class DeadReceiver {

    public static final Logger log = LoggerFactory.getLogger(DynamicDataSourceContextHolder.class);

    @Autowired
    private MqReceiveService mqReceiveService;

    @RabbitHandler
    public void process(String workOrderData) {
        try {
            log.info("收到死信信息 {}",workOrderData);
            mqReceiveService.Ireceive(workOrderData);
        } catch (Exception e) {
            log.warn("死信 {} error");
            throw new AjaxException("error");
        }
    }
}
